Skip to content

chore: Exclude more packages #950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sommeeeer
Copy link
Contributor

@sommeeeer sommeeeer commented Aug 5, 2025

Add more packages that can be excluded so they don't get copied into the final bundles node_modules. Also add debug to determine which packages actually gets skipped. I've run the E2E successfully. These packages will be skipped now:

  • typescript
  • next/dist/compiled/babel
  • next/dist/compiled/babel-packages
  • next/dist/compiled/amphtml-validator

It will decrease the unzipped folder by 15mb and the zipped one with 4mb:

❯ du -hs * | sort -rh
46M	with-deps
31M	without-deps
11M	lambda-with-deps.zip
7,0M	lambda-without-deps.zip

Copy link

changeset-bot bot commented Aug 5, 2025

🦋 Changeset detected

Latest commit: cf8ce94

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@opennextjs/aws Patch
app-pages-router Patch
app-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented Aug 5, 2025

Open in StackBlitz

pnpm add https://pkg.pr.new/@opennextjs/aws@950

commit: cf8ce94

function isExcluded(srcPath: string) {
return EXCLUDED_PACKAGES.some((excluded) =>
function isExcluded(srcPath: string): string | undefined {
return EXCLUDED_PACKAGES.find((excluded) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use find here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same reason. I wanted to keep track of the packages that gets excluded. So we can logger.debug them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's useful at all, or at least i don't see how. I'd rather have this documented in the docs

@@ -250,11 +254,17 @@ File ${serverPath} does not exist

// Only files that are actually copied
const tracedFiles: string[] = [];

// Packages that are excluded and not copied
const excludedPackages = new Set<string>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a Set here ?

// We don't want to copy excluded packages (e.g. sharp)
const excluded = isExcluded(from);
if (excluded) {
if (excluded && !excludedPackages.has(excluded)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't understand the logic. What was the issue with the isExcluded from before ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to add a debug for the packages that actually gets excluded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants